<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/include.jsp"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>分配角色</title>
</head>
<body>
<div class="main">
<div class="main_title"><b>你当前的位置</b>：账户管理-分配角色</div>
<s:form action="user!addRoleSub.action" namespace="/user" >
	<table align="center"  cellpadding="1" cellspacing="1" class="tablelist">	
		<s:if test="user.id != null">
			<s:hidden name="user.id"/>
		</s:if>
		<s:if test="hasErrors()">
			<s:if test="hasFieldErrors()">
				<tr align="center">
					<td colspan="2" align="center" style="background:#eff6fb;padding: 0 5px 0 0;"><font color="red" size="4"><s:fielderror/></font></td>
				</tr>
			</s:if>
			<s:if test="hasActionErrors">
				<tr align="center">
					<td style="background:#eff6fb;padding: 0 5px 0 0;"><font color="blue"><s:actionerror/></font></td>
					<td class="tableHeader2"></td>
				</tr>
			</s:if>	
		</s:if>
		<tr class="listr2">
			<td width="30%" align="right">用户名 </td>
			<td align="left" class="listr5">&nbsp;<s:property value="user.name"/></td>
		</tr>
		<tr class="listr2">
			<td width="30%" align="right">已有角色 </td>
			<td align="left" class="listr5">
				<table>
					<s:iterator value="hasroles">
						<tr><td>
							&nbsp;<s:property value="detail"/>(<s:property value="name"/>)
						</td>
						<td>	
							<s:if test="canUse == true">可用</s:if>
							<s:else>不可用</s:else>
							<s:if test="canGrant == true">可分配</s:if>
							<s:else>不可分配</s:else>
						</td></tr>	
					</s:iterator>
				</table>
			</td>	
		</tr>
	<s:if test="null == roles || roles.isEmpty()">
		<tr class="listr4">    		
			<td colspan="2">
				<input name="back" type="button" class="btn" onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" value="返回" onclick="location.href='user!listUserPage.action'" />
			</td>	
		</tr>
	</table>
	</s:if>
	<s:else>
		<tr class="listr2">
			<td width="30%" align="right">可分配角色 </td>
			<td align="left" class="listr5">
				<table>
					<s:iterator value="roles"  status="status">
						<tr>
							<td>
								&nbsp;<s:property value="status.count"/>
								<s:property value="detail"/>(<s:property value="name"/>)
							</td>
							<td>	
								<s:hidden name="roles[%{#status.index}].id" value='%{id}'/>
								<s:checkbox id="canUse" name ="roles[%{#status.index}].canUse">可用</s:checkbox>
								<s:checkbox id="canGrant" name ="roles[%{#status.index}].canGrant">可分配</s:checkbox>
							<td>	
						</tr>	
					</s:iterator>
				</table>
		</tr>	
		<tr class="listr4">    		
			<td colspan="2">	
				<s:submit cssClass="btn" onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" value="确定" ></s:submit>
				<input name="back" type="button" class="btn" onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" value="返回" onclick="location.href='user!listUserPage.action'" />
			<td>	
		</tr>	
	</table>
	
	</s:else>
	</s:form>
	
	<table>
		<s:form action="user!deleteRole.action" namespace="/user">
		<tr>
			<td></td>
		</tr>
		</s:form>
	</table>
</body>
</html>